﻿using System.Diagnostics;
using ResPackClient.DataBase;
using System.Windows;

namespace ResPackClient
{
    /// <summary>
    /// Interaction logic for ModifyWorkSpace.xaml
    /// </summary>
    public partial class ModifyWorkSpace : Window
    {
        public ModifyWorkSpace(ResPackDataSet dataset)
        {
            InitializeComponent();
            _cbWorkSpace.DataContext = dataset.tbWorkSpace;
        }

        public int PrimaryKey
        {
            get
            {
                Debug.Assert(_cbWorkSpace.SelectedIndex > -1);
                Debug.Assert(_cbWorkSpace.SelectedItem.GetType() == typeof(ResPackDataSet.tbWorkSpaceRow));

                return ((ResPackDataSet.tbWorkSpaceRow)_cbWorkSpace.SelectedItem).PK_ID;
            }
        }
        public string OldWorkSpaceName
        {
            get
            {
                Debug.Assert(_cbWorkSpace.SelectedIndex > -1);
                Debug.Assert(_cbWorkSpace.SelectedItem.GetType() == typeof(ResPackDataSet.tbWorkSpaceRow));

                return ((ResPackDataSet.tbWorkSpaceRow)_cbWorkSpace.SelectedItem).name;
            }
        }

        public string WorkSpaceName { get { return _txtWorkSpace.Text; } }   

        private void OnOk(object sender, RoutedEventArgs e)
        {
            DialogResult = true;
            this.Close();
        }
    }
}
